'use strict';
exports.main = async (event, context) => {
	//event为客户端上传的参数
	console.log('event : ', event)

	var db = uniCloud.database()
	const dbCmd = db.command
	var $ = db.command.aggregate
	return db.collection('user-list').aggregate().match({
		_id: event._id
	}).lookup({
		from: "uni-id-roles",
		localField: 'role_id',
		foreignField: '_id',
		as: 'user_show'
	}).replaceRoot({
		newRoot: $.mergeObjects([$.arrayElemAt(['$user_show', 0]), '$$ROOT'])
	}).project({
		user_show: 0
	}).end()


	// return	
};

// function get_role(res){
// 	console.log(res)
// }